#ifndef SETTINGMANAGER_H
#define SETTINGMANAGER_H

#include <qsettings.h>


class SettingManager
{
public:
    SettingManager(const QString& group);
    ~SettingManager();
    // 获取值（支持模板类型）
    template<typename T>
    T getValue(const QString& key, const T& defaultValue = T()) const {
        m_settings->beginGroup(m_group);
        T value = m_settings->value(key, defaultValue).template value<T>();
        m_settings->endGroup();
        return value;
    }

    // 设置值（支持模板类型）
    template<typename T>
    void setValue(const QString& key, const T& value) {
        m_settings->beginGroup(m_group);
        m_settings->setValue(key, value);
        m_settings->endGroup();
    }
private:
    QSettings* m_settings;
    QString m_group;
};

#endif // SETTINGMANAGER_H
